package com.annhoa.infrastructure.util.aes;

import java.io.ByteArrayOutputStream;
import java.io.IOException;


public class Base64 {
    private static final Encoder encoder = new Encoder();

    public Base64() {
    }

    public static byte[] encode(byte[] data) {
        ByteArrayOutputStream bOut = new ByteArrayOutputStream();

        try {
            encoder.encode(data, 0, data.length, bOut);
        } catch (IOException var3) {
            throw new RuntimeException("encoding base64 exception: " + var3);
        }

        byte[] ret = bOut.toByteArray();
        return ret;
    }

    public static byte[] decode(byte[] data) {
        ByteArrayOutputStream bOut = new ByteArrayOutputStream();

        try {
            String ss = new String(data);
            encoder.decode(ss, bOut);
        } catch (IOException var3) {
            throw new RuntimeException("decoding base64 exception: " + var3);
        }

        return bOut.toByteArray();
    }
}